package com.icode.core.model;

import com.icode.core.dto.house.HouseInfoDTO;
import com.icode.core.model.house.BuildingTypeImage;
import com.icode.core.model.house.HouseInfo;
import com.icode.core.model.house.HouseInfoEquipment;
import com.icode.core.shared.GuidGenerator;
import com.icode.core.shared.JodaTimeUtils;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;

import javax.persistence.*;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ZhongGang
 * Date: 13-6-22
 * Time: 下午4:09
 */
@MappedSuperclass
public abstract class AbstractEntity {
    @Id
    @GeneratedValue
    private Integer id;

    @Column
    @Version
    private Integer version = 0;

    @Column(columnDefinition = "bit")
    private Boolean active = Boolean.TRUE;

    @Column
    private String guid = GuidGenerator.generate();

    @Column(name = "create_time", columnDefinition = "datetime")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime createTime = JodaTimeUtils.now();

    @Column(name = "last_modify_time", columnDefinition = "datetime")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime lastModifyTime = JodaTimeUtils.now();

    public String guid() {
        return this.guid;
    }

    public String id() {
        return this.id + "";
    }

    public void setId(int id) {
        this.id = id;
    }

    public boolean isActive() {
        return this.active;
    }

    public void active() {
        this.active = true;
    }

    public DateTime createTime() {
        return createTime;
    }


}
